The present disclosure relates to transaction processing, and more specifically, to a method, device and computer program product for transaction processing.
In transaction processing, a Two Phase Commit (hereinafter “2PC”) protocol is widely used. The 2PC protocol is a type of atomic commitment protocol, which can be used to maintain data consistency in a distributed transaction environment where a plurality of transaction managers (hereinafter “TM”s) and a set of resource managers (hereinafter “RM”s) work together as a unit of work. The 2PC protocol can appoint a TM in the distributed transaction environment as a coordinator, and appoint other TMs as participants. In the first phase of 2PC, the coordinator attempts to prepare all of the participants associated with a transaction to take necessary steps for either committing or aborting the transaction. Each of the participants can reply either “YES” for committing the transaction, or “NO” for aborting the transaction. In the second phase of 2PC, the coordinator makes a decision on whether to commit or abort the transaction and sends the decision to all of the participants. In response to receiving the decision from the coordinator, each of the participants executes an operation accordingly.
However, before sending out the decision, the coordinator may have a failure. In this case, the participants may wait for an extended period of time for the decision from the coordinator. This may impact performance of the transaction processing, since the participants will not release shared resources during the waiting time. Additionally, if the coordinator has sent the decision to a subset of the participants and then fails, the subset of the participants will execute the decision while remainder of the participants may have to make a heuristic decision until time out. The heuristic decision may be opposite to the decision made by the coordinator, resulting in inconsistency of data.